{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "# data2['day']=pd.DatetimeIndex(data2['Date']).day\n",
    "def xiuxi(a):\n",
    "    feigongzuori=[5,6,7,13,14,20,21,29,30]\n",
    "    return a in feigongzuori\n",
    "def gongzuo(a):\n",
    "    feigongzuori=[5,6,7,13,14,20,21,29,30]\n",
    "    return a not in feigongzuori\n",
    "feigong=data2.loc[data2['day'].apply(xiuxi)]\n",
    "gongzuori=data2.loc[data2['day'].apply(gongzuo)]\n",
    "t=[]\n",
    "plt.rcParams['font.sans-serif']='SimHei'   # 显示中文\n",
    "plt.rcParams['axes.unicode_minus']=False  # 显示负号\n",
    "\n",
    "for i in range(1,25):\n",
    "    t.append(sum(feigong['hour']==i)/len(feigong['hour']))\n",
    "plt.plot(range(1,25),t,'g-',label='非工作日')\n",
    "plt.xticks(range(1,25))\n",
    "tt=[]\n",
    "for i in range(1,25):\n",
    "    tt.append(sum(gongzuori['hour']==i)/len(gongzuori['hour']))\n",
    "plt.plot(range(1,25),tt,'b-',label='工作日')\n",
    "plt.xticks(range(1,25))\n",
    "plt.legend()\n",
    "plt.savefig('就餐峰值.jpg')\n",
    "#横轴是时间分布，纵轴是时间占比"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
